<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>{{num}}</h2>
        <h2>{{msg}}</h2>
        <button v-on:click="changeNum">改变nun</button>
    </div>
</body>
<script>
    var index = 1;
    const vm = new Vue({
        el: "#app",
        data: {
            msg: "hi vue ",
            num: 0
        },
        methods: {
            log(msg) {
                console.log(`## ${++index}  -- ${msg} `)
            },
            changeNum() {
                this.num++;
            }
        },
        // 生命周期
        beforeCreate() {
            console.log(this)
            // this.log('beforeCreate 实例创建之前')
            console.log(`## ${++index}  -- beforeCreate 实例创建之前 `)
        },
        created() {
            this.log('created 实例被创建完成')
        },
        beforeMount() {
            this.log('beforeMount 实例被载入之前 ')
        },
        mounted() {
            this.log('mounted 实例被载入完成了 ')
        },
        beforeUpdate() {
            this.log('beforeUpdate - 实例的数据被修改之前' + this.msg)
        },
        updated() {
            this.log('updated - 实例的数据被修改完成')
        },
        beforeDestroy() {
            this.log('beforeDestroy - 实例被销毁之前 ')
        },
        destroyed() {
            this.log('destroyed - 实例被销毁完成 ')
        }
    })//vm.$destroyed()
    setTimeout(function () {
        vm.msg = "change .......";
    }, 3000)
</script>

</html>